package com.library.service.serviceImpl;

import com.library.entity.Questions;
import com.library.entity.Results;
import com.library.mapper.ResultsMapper;
import com.library.service.IResultsService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 至尊伍人组
 * @since 2018-09-30
 */
@Service
public class ResultsServiceImpl extends ServiceImpl<ResultsMapper, Results> implements IResultsService {
	@Autowired
	ResultsMapper resultsMapper;

	@Override
	public boolean addResults(Results results) {
		int flag=resultsMapper.insert(results);
		if(flag==0)
			return false;
		return true;
	}

	@Override
	public List<Results> showPageResultsAdmin(int current, int size, int lessonId) {
		List<Results> results=resultsMapper.selectPage(new RowBounds(current, size), 
				new EntityWrapper<Results>().eq("lessonId", lessonId));
		return results;
	}

	@Override
	public List<Results> showPageResultsViditor(int current, int size, int readerId) {
		List<Results> results=resultsMapper.selectPage(new RowBounds(current, size), 
				new EntityWrapper<Results>().eq("readerId", readerId));
		return results;
	}
	
	
}
